package com.ckh.springboot.controller;

import com.ckh.springboot.common.Result;
import com.ckh.springboot.entity.QuestionType;
import com.ckh.springboot.service.IQuestionTypeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/questionType")
public class QuestionTypeController {

    @Resource
    private IQuestionTypeService questionTypeService;

    @GetMapping("/list")
    public Result list() {
        List<QuestionType> list = questionTypeService.list();
        return Result.success(list);
    }

    @PostMapping("/create")
    public Result create(@RequestBody QuestionType questionType) {
        questionTypeService.save(questionType);
        return Result.success();
    }

    @PostMapping("/update")
    public Result update(@RequestBody QuestionType questionType) {
        questionTypeService.updateById(questionType);
        return Result.success();
    }

    @PostMapping("/delete")
    public Result delete(@RequestParam Integer id) {
        questionTypeService.removeById(id);
        return Result.success();
    }
}